﻿using Cxuu.Models;
using Cxuu.Service;
using Microsoft.AspNetCore.Mvc;
using PetaPoco;
using System.Threading.Tasks;

namespace Cxuu.Web.Home
{
    [Area("Home")]
    public class ContentController : Base
    {
        private readonly ContentService _contentService;
        private readonly ContentCateService _contentCateService;

        public ContentController(ContentService contentService, ContentCateService contentCateService)
        {
            _contentService = contentService;
            _contentCateService = contentCateService;
        }

        /// <summary>
        /// 全部内容页列表 分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> IndexAsync(int page = 1, int limit = 15)
        {
            ContentQuery articleQuery = new()
            {
                CurrentPage = page,
                Limit = limit
            };
            Page<ViewContentAndCate> viewArticleAndCates = await _contentService.GetListAsync(articleQuery);
            return View(viewArticleAndCates);
        }
       
    }
}
